import types from './types'
import Model from '../../../models/apps'

export default {
  /**
   * 获取列表
   */
  getApps ({commit}, {params}) {
    return new Model('apps').GET({params}).then((res) => {
      commit(types.GET_APPS, {
        data: res.data
      })
    })
  },

  /**
   * 获取详情
   */
  getApp ({commit}, {uri}) {
    return new Model('app').GET({uri}).then((res) => {
      commit(types.GET_APP, {
        data: res.data
      })
    })
  },

  /**
   * 新增
   */
  postApp ({commit}, {data}) {
    return new Model('app').POST({data})
  },

  /**
   * 编辑
   */
  putApp ({commit}, {uri, data}) {
    return new Model('app').PUT({uri, data})
  },

  /**
   * 删除
   */
  deleteApp ({commit}, {params}) {
    return new Model('app').DELETE({params})
  }
}
